﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using ChinaSoft.Model;
namespace ChinaSoft.BLL
{
	/// <summary>
	/// 系统角色表
	/// </summary>
	public partial class BLL_tb_MidSoft_RtxMessage
	{
		private readonly ChinaSoft.DAL.DAL_tb_MidSoft_RtxMessage dal=new ChinaSoft.DAL.DAL_tb_MidSoft_RtxMessage();
		public BLL_tb_MidSoft_RtxMessage()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int RtxMessageId)
		{
			return dal.Exists(RtxMessageId);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(ChinaSoft.Model.Model_tb_MidSoft_RtxMessage model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ChinaSoft.Model.Model_tb_MidSoft_RtxMessage model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int RtxMessageId)
		{
			
			return dal.Delete(RtxMessageId);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string RtxMessageIdlist )
		{
			return dal.DeleteList(RtxMessageIdlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ChinaSoft.Model.Model_tb_MidSoft_RtxMessage GetModel(int RtxMessageId)
		{
			
			return dal.GetModel(RtxMessageId);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public ChinaSoft.Model.Model_tb_MidSoft_RtxMessage GetModelByCache(int RtxMessageId)
		{
			
			string CacheKey = "Model_tb_MidSoft_RtxMessageModel-" + RtxMessageId;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(RtxMessageId);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (ChinaSoft.Model.Model_tb_MidSoft_RtxMessage)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_tb_MidSoft_RtxMessage> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_tb_MidSoft_RtxMessage> DataTableToList(DataTable dt)
		{
			List<ChinaSoft.Model.Model_tb_MidSoft_RtxMessage> modelList = new List<ChinaSoft.Model.Model_tb_MidSoft_RtxMessage>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				ChinaSoft.Model.Model_tb_MidSoft_RtxMessage model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new ChinaSoft.Model.Model_tb_MidSoft_RtxMessage();
					if(dt.Rows[n]["RtxMessageId"]!=null && dt.Rows[n]["RtxMessageId"].ToString()!="")
					{
						model.RtxMessageId=int.Parse(dt.Rows[n]["RtxMessageId"].ToString());
					}
					if(dt.Rows[n]["ProjectInfoId"]!=null && dt.Rows[n]["ProjectInfoId"].ToString()!="")
					{
						model.ProjectInfoId=int.Parse(dt.Rows[n]["ProjectInfoId"].ToString());
					}
					if(dt.Rows[n]["ReceiveUserId"]!=null && dt.Rows[n]["ReceiveUserId"].ToString()!="")
					{
						model.ReceiveUserId=int.Parse(dt.Rows[n]["ReceiveUserId"].ToString());
					}
					if(dt.Rows[n]["ReceiveUserName"]!=null && dt.Rows[n]["ReceiveUserName"].ToString()!="")
					{
					model.ReceiveUserName=dt.Rows[n]["ReceiveUserName"].ToString();
					}
					if(dt.Rows[n]["MessageContent"]!=null && dt.Rows[n]["MessageContent"].ToString()!="")
					{
					model.MessageContent=dt.Rows[n]["MessageContent"].ToString();
					}
					if(dt.Rows[n]["CreateTime"]!=null && dt.Rows[n]["CreateTime"].ToString()!="")
					{
						model.CreateTime=DateTime.Parse(dt.Rows[n]["CreateTime"].ToString());
					}
					if(dt.Rows[n]["SendUserId"]!=null && dt.Rows[n]["SendUserId"].ToString()!="")
					{
						model.SendUserId=int.Parse(dt.Rows[n]["SendUserId"].ToString());
					}
					if(dt.Rows[n]["SendUserName"]!=null && dt.Rows[n]["SendUserName"].ToString()!="")
					{
					model.SendUserName=dt.Rows[n]["SendUserName"].ToString();
					}
					if(dt.Rows[n]["RtxMessageState"]!=null && dt.Rows[n]["RtxMessageState"].ToString()!="")
					{
					model.RtxMessageState=dt.Rows[n]["RtxMessageState"].ToString();
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

